 {include file="public/header" /}
 {load href="__PLUGINS__bootstrap/bootstrap-table.min.css"}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.js"}
<style type="text/css">
#des,#des input{ width: 40px;text-align:center;}
#id{ width: 78px; }
.bs-checkbox{ width: 36px; height: 40px }
.fixed-table-toolbar .columns,.fixed-table-toolbar .search{margin-left:0px; margin-top: 0px }
#title span{ float: right; margin-left: 3.333px;}
.search{ margin-bottom: 0px !important; }
.asdlkjasd{ background: #1ab394; color: #fff}

</style>
 <body class="gray-bg">
 <div class="wrapper wrapper-content {:config('adminClass.main')}">
    <div class="ibox float-e-margins">
        {include file="public/tophead"}
        {include file="public/top" /}
        <div class="ibox-content">
        {include file="public/topsection"}
            <div class="row row-lg">
                <div class="col-sm-12">

                    <div class="fixed-table-toolbar">
                        <a class="btn btn-default btn-outline {present name='shenhe'}{eq name='shenhe' value='1'}asdlkjasd{/eq}{else /}asdlkjasd{/present}" href="{:url('ping',['shenhe'=>1])}{present name='type'}/type/{$type}{/present}">通过</a>
                        <a class="btn btn-default btn-outline {present name='shenhe'}{eq name='shenhe' value='0'}asdlkjasd{/eq}{/present}" href="{:url('ping',['shenhe'=>0])}{present name='type'}/type/{$type}{/present}">审核</a>
                        <a class="btn btn-default btn-outline {present name='shenhe'}{eq name='shenhe' value='-1'}asdlkjasd{/eq}{/present}" href="{:url('ping',['shenhe'=>-1])}{present name='type'}/type/{$type}{/present}">拒绝</a>
                    </div>
                    
                     
                    
                    <div class="fixed-table-toolbar">
                        <form method="get" action="" style="display: flex;">
                            <div class="pull-left search" style="display: flex;">
                                <div class="columns columns-right btn-group pull-left">
                                    <select class="form-control" name="search">
                                        <option value="content" {php}if(input(
                                        '?param.search')){if(input('param.search')=='content'){echo "selected";}
                                        }{/php}>内容</option>

                                        <option value="dy_id" {php}if(input(
                                        '?param.search')){if(input('param.search')=='dy_id'){echo "selected";}
                                        }{/php}>动态id</option>
                                        <option value="userid" {php}if(input(
                                        '?param.search')){if(input('param.search')=='userid'){echo "selected";}
                                        }{/php}>用户id</option>
                                        <option value="phone" {php}if(input(
                                        '?param.search')){if(input('param.search')=='phone'){echo "selected";}
                                        }{/php}>手机号</option>
                                    </select>
                                </div>

                                <div class="pull-right search">
                                    <input class="form-control input-outline" type="text"
                                           {php}
                                           if(input('?param.name')){
                                    if(input('param.name')){
                                    echo "value='".input('name')."'";
                                    }
                                    }
                                    {/php}
                                    name="name" placeholder="搜索">
                                </div>

                                <div class="pull-right search">
                                    <button style="border-radius:0px; border:1px solid #e5e6e7; border-left:0px"
                                            class="btn btn-default btn-outline" type="submit">搜索
                                    </button>
                                </div>

                                <input name="start" type="text" id="start" class="form-control layui-input" value="{present name='start'}{$start}{/present}" placeholder=" # 起始时间" autocomplete="off" style="height:34px;width:180px;margin:0 10px;">
                                <input name="end" type="text" id="end" class="form-control layui-input" value="{present name='end'}{$end}{/present}" placeholder=" # 结束时间" autocomplete="off" style="height:34px;width:180px;margin:0 10px;">

                                {php}
                                if(input('?param.name')){
                                {/php}
                                <div class="pull-right search">
                                    <a class="btn btn-w-m btn-link" href="{:url('ping')}">返回列表</a>
                                </div>
                                {php}
                                }
                                {/php}

                            </div>
                        </form>
                    </div>
                    <div class="example">
                        <form class="form-horizontal" method="post">
                        <table data-toggle="table">
                            <thead>
                                <tr>
                                    <th class="bs-checkbox"><input type="checkbox" id="delidAll"></th>
                                    <th data-align="center">ID</th>
                                    <th data-align="center">动态ID</th>
                                    <th>用户</th>
                                    <th>评论内容</th>
                                    <th>评论时间</th>
                                    <th>审核时间</th>
                                    <th>审核人</th>
                                    <th data-align="center">状态</th>
                                    <th>管理</th>
                                </tr>
                            </thead> 
                            <tbody id="form">
                                {volist name="data" id="v"}
                                <tr id="id{$v.comment_id}" class="class">
                                    <td id="delid" ><input name="delAll[]" type="checkbox" value="{$v.comment_id}"></td>
                                    <td id="id">{$v.comment_id}</td>
                                     <td>
{$v.dy_id}
                                    </td>

                                    <td>
                                        <a onclick="member('{$v.userid}')" style="color:#40BCF7">{$v.name}</a>({$v.userid})({$v.sex})
                                    </td>
                                    
                                    <td id="title">
                                    {if condition="$v.in_temp"}
                                        <span style="color:red;">(模板)</span>
                                    {/if}
                                        <span style="color:red;">({$v.from?'平台':'用户'})</span>
                                    {:_substr($v['content'])}
                                    </td>
                                    <td> 
                                        <span {php}if(date('Ymd')==$v['addtime'])echo 'style="color: #ed5565"';{/php}>{$v.addtime}</span>
                                    </td>
                                    <td>
                                        <span>{neq name="$v.shenhe_time" value="0"}{:date('Y-m-d H:i:s', $v.shenhe_time)}{/neq}</span>
                                    </td>
                                    <td>
                                        <span>{:_getAdminName($v.shenhe_admin_id)}</span>
                                    </td>
                                    <td id="hide{$v.comment_id}">{if condition="$v.shenhe eq '0'"}<span style="color: #ed5565">审 核</span>{elseif condition="$v.shenhe eq '1'" /}<span style="color: #1ab394">通 过</span>{elseif condition="$v.shenhe eq '-1'" /}<span style="color: #ed5565">拒 绝</span>{/if}</td>
                           
                                    <td>
                                        <div class="btn-group">
                                            <div data-toggle="dropdown" class="btn btn-primary btn-xs dropdown-toggle">操作 <span class="caret"></span>
                                            </div>
                                            <ul class="dropdown-menu">
                                                <li><a onclick="add('{:url('pingAdd',['id'=>$v['comment_id'],'url'=>-1])}')">详细</a>
                                                </li>
                                                <li class="divider"></li>
                                                {switch name="$v.shenhe"}
                                                {case value="-1"}
                                                <li><a onClick="shenhe({$v.comment_id},'0')">审核</a></li>
                                                <li><a onClick="shenhe({$v.comment_id},'1')"><span style="color: #1ab394; ">通过</span></a></li>
                                                {/case}
                                                {case value="0"}
                                                <li><a onClick="shenhe({$v.comment_id},'1')"><span style="color: #1ab394; ">通过</span></a></li>
                                                <li><a onClick="shenhe({$v.comment_id},'-1')"><span style="color: #ed5565; ">拒绝</span></a></li>
                                                {/case}
                                                {case value="1"}
                                                <li><a onClick="shenhe({$v.comment_id},'-1')"><span style="color: #ed5565; ">拒绝</span></a></li>
                                                <li><a onClick="shenhe({$v.comment_id},'0')">审核</a></li>
                                                {/case}
                                                {/switch}
                                                <li class="divider"></li>
                                                <li><a onclick="del('{$v.comment_id}')">删除</a>
                                                </li>
                                            </ul>
                                        </div>
                                    </td>
                                </tr>
                                {/volist}
                            </tbody>
                        </table>
                        </form>
                    </div>
                </div>  
            </div>
            <hr>
            <div class="row row-lg">
                <div class="col-sm-6">
                    <div  class="btn btn-outline btn-default" onclick="alla(1)">
                        批量通过
                    </div>
                    <div  class="btn btn-outline btn-default" onclick="alla(-1)">
                        批量拒绝
                    </div>
                    <div  class="btn btn-outline btn-default" onclick="alla(0)">
                        批量审核
                    </div>
                    <a href="?order=1" type="button" class="btn btn-outline btn-default">
                        倒序排序
                    </a>
                    <a href="?order=2" type="button" class="btn btn-outline btn-default">
                        顺序排序
                    </a>
                    <div  class="btn btn-outline btn-default" onclick="alla('del')">
                        批量删除
                    </div>
                    <div  class="btn btn-outline btn-default" onclick="alla('temp')">
                        批量设为系统评论模板
                    </div>

                </div>
                <div class="col-sm-6 pages">{$page}</div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script type="text/javascript">
$(document).ready(function(){
        $('#delidAll').click(function(){
            $('input[type=checkbox]').each(function(){
                var self=$(this);
                if(!self.prop('checked')){
                    self.prop('checked',true);
                }else{
                    self.prop('checked',false);
                }
            });
        })
});
    layui.use(['laydate'], function(){
        var laydate = layui.laydate;

        laydate.render({
            elem: '#start' //指定元素
            ,type: 'datetime'
            ,trigger: 'click'
        });

        laydate.render({
            elem: '#end' //指定元素
            ,type: 'datetime'
            ,trigger: 'click'
        });
    })
function del(id){
    swal_del(id,"{:url('pingDel')}")
}
function alla(types){
    var all=$(".form-horizontal").serialize();
    var alls=$(".form-horizontal").serializeArray();
    console.log(JSON.stringify(alls))

    ajaxFun("post",'{:url('article/shenhePingAll')}?type='+types,all,'json',function(ret){

        if(ret){
            var text
            switch(types)
            {
                case -1:
                    text = '<span class="btn btn-primary btn-xs" style="background-color: #414141;border-color:#414141">拒 绝</span>';
                    break;
                case 0:
                    text = '<span class="btn btn-default btn-xs">审 核</span>';
                    break;
                case 1:
                    text = '<span class="btn btn-primary btn-xs">通 过</span>';
                    break;
            }
            for(var i=0;i<alls.length;i++){
                if(types=='del'){
                    $('#id'+alls[i]['value']).remove();
                }else if(types=='temp'){
                }else{
                    $('#hide'+alls[i]['value']).html(text);
                }
            }

            swal_msg('操作成功')
        }
    })

}
 
function shenhe(id,value){
    ajaxFun("post","{:url('pingshenhe')}",{id:id,shenhe:value},'json',function(ret){
        if(ret){
            if(ret.ret){
                layer.msg(ret.ret)
                /*$("#id"+id).hide('fast',function(){
                     $("#id"+id).remove();
                })*/
                window.location.reload()
            }else{
                layer.msg(ret.err)
            }
        }else{
            swal_msg("错误",ret,"error");
        }
    })
}

function member(id)
{
    layui.use('layer', function(){
        var layer = layui.layer;
        layer.open({
            title :'预览',
            area: ['100%', '100%'],
            type: 2,
            content: '{:url("member/index")}?search=id&name='+id
        });
    });
}
</script>
 